#define _CRT_SECURE_NO_WARNINGS 1



#include <stdio.h>

int main()
{
	int m = 0;
	scanf("%d", &m);
	int count = m;

	while (m /= 2)
	{
		count += m;
	}

	printf("%d\n", count);

	return 0;
}